package com.googlecode.marrowboy.assertionresult;

/**
 * Used internally to store details of individual assertions.
 * 
 * @author mjg
 */
public class AssertionDetail {

	private String reason;
	private final String actual;
	private final String expected;

	private int lineNumber;
	private String filename;

	private final boolean wasSuccessful;

	/**
	 * Constructor which sets mandatory fields
	 * 
	 * @param reason
	 *            explanation of why the assertion was performed
	 * @param actual
	 *            the actual value asserted on
	 * @param expected
	 *            the description of what was expected
	 * @param wasSuccessful
	 *            did the assertion pass?
	 */
	public AssertionDetail(String reason, String actual, String expected, boolean wasSuccessful) {
		this.reason = reason;
		this.actual = actual;
		this.expected = expected;
		this.wasSuccessful = wasSuccessful;
	}

	/**
	 * Allows fluent setting of the reason attribute.
	 * 
	 * @param reason
	 *            explanation of why the assertion was performed
	 */
	public void because(String reason) {
		this.reason = reason;
	}

	/**
	 * Getter.
	 * 
	 * @return the actual value asserted on
	 */
	public String getActual() {
		return actual;
	}

	/**
	 * Getter.
	 * 
	 * @return the description of what was expected
	 */
	public String getExpected() {
		return expected;
	}

	/**
	 * Getter
	 * 
	 * @return explanation of why the assertion was performed
	 */
	public String getReason() {
		return reason;
	}

	/**
	 * Getter
	 * 
	 * @return whether or not the assertion passed
	 */
	public boolean wasSuccessful() {
		return wasSuccessful;
	}

	/**
	 * Setter
	 * 
	 * @param lineNumber
	 *            the line number in the source file where the assertion was
	 *            called from.
	 */
	public void setLineNumber(int lineNumber) {
		this.lineNumber = lineNumber;
	}

	/**
	 * Getter
	 * 
	 * @return the line number in the source file where the assertion was called
	 *         from.
	 */
	public int getLineNumber() {
		return lineNumber;
	}

	/**
	 * Setter
	 * 
	 * @param filename
	 *            the name of the source file name for the test where the
	 *            assertion is called
	 */
	public void setFilename(String filename) {
		this.filename = filename;
	}

	/**
	 * Getter
	 * 
	 * @return the name of the source file name for the test where the
	 *         assertion is called
	 */
	public String getFilename() {
		return filename;
	}

}
